package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.common.CommonResult;
import com.neuedu.yyzx.entity.ServiceHouse;
import com.neuedu.yyzx.service.IServiceHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 服务对象（管家）  前端控制器
 * </p>
 *
 * @author dya
 * @since 2021-04-27
 */
@RestController
@RequestMapping("//serviceHouse")
public class ServiceHouseController {

    @Autowired
    IServiceHouseService serviceHouseService;

    @RequestMapping("/list")
    CommonResult list(Page page, ServiceHouse serviceHouse){
        QueryWrapper queryWrapper=new QueryWrapper();
        if (serviceHouse!=null && StringUtils.isNotEmpty(serviceHouse.getHouseName())){
            queryWrapper.like("house_name",serviceHouse.getHouseName()) ;
        }
        return CommonResult.success(serviceHouseService.page(page,queryWrapper));
    }

    @RequestMapping("/add")
    CommonResult add(ServiceHouse serviceHouse){
        return CommonResult.success(serviceHouseService.saveOrUpdate(serviceHouse));
    }

    @RequestMapping("/getById")
    CommonResult getById(Integer houseId){
        return CommonResult.success(serviceHouseService.getById(houseId));
    }

    @RequestMapping("/del")
    CommonResult del(Integer houseId){
        return CommonResult.success(serviceHouseService.removeById(houseId));
    }

}
